package com.sc.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.sc.bean.GoodsBean;

public class GoodsData {

	private static GoodsData instance = null;
	public static GoodsData getInstance(){
		if(instance == null) instance = new GoodsData();
		return instance;
	}
	private GoodsData(){
		goods = new ArrayList<GoodsBean>();
		goodsMap = new HashMap<Long, GoodsBean>();
		for (int i = 0; i < 100; i++) {
			GoodsBean g = new GoodsBean(1001L +i, "手机" +i, 1000+i*100);
			goods.add(g);
			goodsMap.put(g.getId(), g);
		}
		
	}
	//////////////////////////////////
	
	private List<GoodsBean> goods = null;
	private Map<Long, GoodsBean> goodsMap = null;
	public void add(GoodsBean g){
		goods.add(g);
	}
	
	public List<GoodsBean> getGoods() {
		return goods;
	}
	
	public GoodsBean getById(Long id){
		return goodsMap.get(id);
	}

}
